package com.rongke.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rongke.mapper.OperationRecordMapper;
import com.rongke.model.OperationRecord;
import com.rongke.service.OperationRecordService;

import org.springframework.stereotype.Service;

/**
 * 手术记录
 */
@Service
public class OperationRecordServiceImpl extends ServiceImpl<OperationRecordMapper, OperationRecord>
                                                                                                   implements
                                                                                                   OperationRecordService {

    @Override
    public List<OperationRecord> selectByMrId(long mrId) {
        EntityWrapper<OperationRecord> ew = new EntityWrapper<>();
        ew.eq("medical_record_id", mrId);
        ew.orderBy("date");

        return baseMapper.selectList(ew);
    }

    @Override
    public List<OperationRecord> selectByMrIdAndDate(long mrId, String startDate) {
        EntityWrapper<OperationRecord> ew = new EntityWrapper<>();
        ew.eq("medical_record_id", mrId);
        ew.ge("date", startDate);
        ew.orderBy("date", false);

        return baseMapper.selectList(ew);
    }

    @Override
    public List<OperationRecord> selectByMrIdAndType(long mrId, Integer[] typeIds) {
        EntityWrapper<OperationRecord> ew = new EntityWrapper<>();
        ew.eq("medical_record_id", mrId);
        ew.in("type_id", typeIds);
        ew.orderBy("date", false);

        return baseMapper.selectList(ew);
    }
}
